package cs1;

import java.util.ArrayList;

public class cs2 {
    public static void main(String[] args) {
        //创建集合对象
        ArrayList<Student> list = new ArrayList<>();
        //创建学生对象
        Student stu1 = new Student("张三1",23,"男");
        Student stu2 = new Student("张三2",23,"男");
        Student stu3 = new Student("张三3",23,"女");
        //添加学生到对象集合中
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        //遍历集合，采用通用遍历格式
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println(stu.getMing()+"---"+stu.getNianling());
        }
    }
}
